﻿@model Zor_Web.Models.Base.V_Disannul
@using Webdiyer.WebControls.Mvc;
@using Zor_Tools;
@{
    Layout = null;
}
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>汇总管理</title>
    <link href="~/Content/LayerUI/src/css/layui.css" rel="stylesheet" />
    <link href="~/Content/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/Styles/zor.css" rel="stylesheet" />
    <!-- 框架必要 -->
    <script src="~/Content/Scripts/jquery/jquery-1.9.1.min.js"></script>
    <script src="~/Content/Scripts/learunui-framework.js"></script>
    <script src="~/Content/Scripts/Zor_AJax.js"></script>
    <!-- 消息提示 -->
    <script language='javascript' src='~/Content/layer/layer.js'></script>
    <!-- 日期选择器 -->
    <script src="~/Content/laydate/laydate.js"></script>
    <!-- 表单验证 -->
    <script src="~/Content/Scripts/JValidator.js"></script>
    <!-- 打印控件 -->
    <script src="~/Zor/Lodop/LodopFuncs.js"></script>
    <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
        <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
    </object>   
     <!-- 打印单样式 -->
    <style type="text/css">
            .h1 {
                font-size: 31px;
                font-weight: normal;
                margin-top: 70px;
                margin-bottom: 30px;
            }

            .p1 {
                margin-left: 40px;
                font-size: 18px;
            }

            .label1 {
                padding-left: 5px;
                padding-right: 5px;
                text-decoration: underline;
            }

            .table-c table {
                font-size: 14px;
                text-align: center;
                border-right: 1px solid;
                border-bottom: 1px solid;
            }

                .table-c table th {
                    font-size: 14px;
                    text-align: center;
                    border-left: 1px solid;
                    border-top: 1px solid;
                }

                .table-c table td {
                    font-size: 14px;
                    text-align: center;
                    border-left: 1px solid;
                    border-top: 1px solid;
                }

            .location {
                margin-left: 100px;
            }
    </style>
</head>
<body class="gray-bg">
    <!-- 打印模态 -->
    <div id="form1" hidden align="center" aria-hidden="true" data-backdrop="static">
        <div id="modalPrint">
            <div align="center">
                <font size="6">汇总单</font>
            </div><br/>
            <table width="700" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td>汇总部门：</td>
                    <td><u id="Dt_Name"></u></td>
                    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
                    <td>份数：</td>
                    <td><u id="Copies"></u></td>
                    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                </tr>
                <tr>
                    <td>总金额：</td>
                    <td><u id="SumMoney"></u></td>
                    <td></td>
                    <td>汇总时间：</td>
                    <td><u id="Sm_Date"></u></td>
                    <td></td>
                </tr>
            </table>
            <br/>
            <div class="table-c">
                <table align="center" width="700" border="1" cellspacing="0" cellpadding="0">
                    <thead>
                        <tr>
                            <th>序号</th>
                            <th>受理单号</th>
                            <th>身份证号</th>
                            <th>纳税人</th>
                            <th>完税证号</th>
                            <th>开票日期</th>
                            <th>房产税</th>
                            <th>个人所得税</th>
                            <th>税额</th>
                        </tr>
                    </thead>
                    <tbody align="center" id="accordiondPrint"></tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="layui-tab layui-tab-brief main-tab-container ">
        <div class="col-sm-12 ct-padding">
            <div class="col-sm-8 ct-padding">
                <button id="btnInvoice" class="layui-btn layui-btn layui-btn-small"><span class="glyphicon glyphicon-ok"></span> 汇总</button>
                <button id="btnUpdate" class="layui-btn layui-btn-normal layui-btn-small"><span class="glyphicon glyphicon-share-alt"></span> 取消汇总</button>
                <button id="btnSearchFull" class="layui-btn  layui-btn-normal layui-btn-small"><span class="glyphicon glyphicon-search"></span>查询</button>
                <button id="btnPrint" class="layui-btn  layui-btn-steelblue  layui-btn-small"><span class="glyphicon glyphicon-print"></span>打印</button>
                <button id="btnMessage" class="layui-btn layui-btn-orchid layui-btn-small"><span class="glyphicon glyphicon-list-alt"></span>详情</button>
                <button id="btnRefresh" class="layui-btn layui-btn-blue layui-btn-small"><span class="glyphicon glyphicon-repeat"></span>刷新</button>
            </div>
        </div>
        <div class="layui-tab-content">
            <table class="layui-table" lay-skin="line">
                <thead>
                    <tr>
                        <th hidden></th>
                        <th></th>
                        <th>汇总单号</th>
                        <th>操作员名称</th>
                        <th>汇总金额(元)</th>
                        <th>汇总时间</th>
                        <th>消号状态</th>
                    </tr>
                </thead>
                <tbody id="accordion">
                    @foreach (var item in Model.PageData)
{
    <tr>

        <td hidden>@item.Dn_Id</td>
<td><input type="radio" name="chk" id="@item.Dn_Id" value="@item.Dn_Id" /></td>
<td>@item.Dn_Number</td>
<td>@item.DnUser</td>
<td>@(item.Dn_ActtualTax * 0.01)</td>
<td>@TimeHelper.TimeStampToDateTime(item.Dn_Date.ToString(), TimeHelper.ToTimeType.link_ymd)</td>
<td>@item.DnState</td>
<td hidden>@item.Acceptance_Id</td>
</tr>
}
</tbody>
</table>
<div class="col-sm-12">
    <div class="col-sm-10">
        @Html.Pager(Model.PageData, new PagerOptions { PageIndexParameterName = "index", ContainerTagName = "ul", PrevPageText = "上页", NextPageText = "下页", FirstPageText = "首页", LastPageText = "尾页", CssClass = "pagination", PagerItemsSeperator = "", CurrentPagerItemWrapperFormatString = "<li class=\"active\"><a href=\"#\">{0}</a></li>", PagerItemWrapperFormatString = "<li>{0}</li>" }, new { id = "bootstrappager", @class = "pagination" })
</div>
<div class="col-sm-2 to-righjt">
    共 @Model.PageData.TotalItemCount 条记录，页 @Model.PageData.CurrentPageIndex/@Model.PageData.TotalPageCount
</div>
</div>
</div>
</div>

@using (Html.BeginForm("Zor_Summary", "Base", new RouteValueDictionary { { "Model", Model } }, FormMethod.Get))
{
    <!-- 查询模态框 -->
    <div id="myModalSearch" hidden data-backdrop="static">
        <div id="divfrom" class="layui-tab-content">
            <form method="get" class="form-horizontal m-t">
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">汇总起始时间：</label>
                    <div class="col-sm-4">
                        <input id="In_Date" name="In_Date" type="text" class="laydate-icon  form-control layer-date" value="@Model.Dn_Date">
                    </div>
                    <label class="col-sm-2 layui-form-label">汇总结束时间：</label>
                    <div class="col-sm-4">
                        <input id="In_Date" name="In_Date" type="text" class="laydate-icon form-control layer-date" value="@Model.Dn_Date">
                    </div>
                </div>
            </form>
            <div class="box-footer">
                <button type="submit" class="layui-btn layui-btn-normal layui-btn-small pull-right">
                    <i class="fa fa-search"></i>查询
                </button>
            </div>
        </div>
    </div>
}

<!-- 详情列表 -->
<div id="myModalMessage" hidden data-backdrop="static">
    <div class="col-sm-12  layui-tab-content">
        <div class="mail-box" style="overflow-x:scroll;white-space:nowrap;">
            <table class="layui-table" lay-skin="line">
                <thead>
                    <tr>
                        <th hidden></th>
                        <th>社区</th>
                        <th>受理单号</th>
                        <th>税金(元)</th>
                        <th>起征日期</th>
                        <th>征止日期</th>
                        <th>缴税日期</th>
                        <th>经办人</th>
                        <th>房屋属性</th>
                        <th>纳税人</th>
                        <th>联系方式</th>
                        <th>面积</th>
                    </tr>
                </thead>
                <tbody id="accordiond"></tbody>
            </table>
        </div>
    </div>
</div>

</body>
</html>

<script>

    // 打印份数
    function GetCopies(Id) {
        var html = "";
        getAjax("/Base/Copies", { "Id": Id }, function (data) {
            accordionJson = eval("(" + data + ")");
            $.each(accordionJson, function (i) {
                html += accordionJson[i].Copies;
                $("#Copies").html(html);
            });
        });
    }
    // 打印总金额
    function SumMoney(Id) {
        var html = "";
        getAjax("/Base/SumMoney", { "Id": Id }, function (data) {
            accordionJson = eval("(" + data + ")");
            $.each(accordionJson, function (i) {
                html += ((accordionJson[i].SumMoney) * 0.01).toFixed(2);
                $("#SumMoney").html(html);
            });
        });
    }
    // 汇总时间
    function Sm_Date(Id) {
        var html = "";
        getAjax("/Base/Sm_Date", { "Id": Id }, function (data) {
            accordionJson = eval("(" + data + ")");
            $.each(accordionJson, function (i) {
                html += DataIntToDate(accordionJson[i].Sm_Date, 'yyyy-MM-dd hh:mm:ss');
                $("#Sm_Date").html(html);
            });
        });
    }
    /**
* 获取所属部门名称
*/
    function GetDtName() {
        var html = "";
        getAjax("/Base/GetDtName", "", function (data) {
            accordionJson = eval("(" + data + ")");
            $.each(accordionJson, function (i) {
                html += accordionJson[i].Dt_Name;
                $("#Dt_Name").html(html);
            });

        });
    }
    /*** 打印列表*/
    function GetAccordionMenu() {
        var checkId = CheckboxValueIDs();       //主id
        if (checkId.length == 0) {
            layer.msg("请选择要打印的信息！");                                                             //未选中任何行
            return;
        }
        if (checkId.length > 1) {
            layer.msg("只能选择一条信息");                                                             //未选中任何行
            return;
        }
        GetDtName(checkId[0]);
        GetCopies(checkId[0]);
        SumMoney(checkId[0]);
        Sm_Date(checkId[0]);
        var html = "";
        getAjax("/Base/Print_Summary", { "where": checkId[0] }, function (data) {
            var accordionJson = eval(data);
            $.each(accordionJson, function (i) {
                html += "<tr>";
               // html += "<td hidden>" + accordionJson[i].Acceptance_TicketNumber + "</td>";
                html += "<td>" + accordionJson[i].rowId + "</td>";
                html += "<td>" + accordionJson[i].Acceptance_TicketNumber + "</td>";
                html += "<td>" + accordionJson[i].NatPer_IDNumber + "</td>";
                html += "<td>" + accordionJson[i].NatPer_Name + "</td>";
                html += "<td>" + accordionJson[i].Pt_CertificateNumber + "</td>";
                html += "<td>" + accordionJson[i].Pt_Date + "</td>";
                html += "<td>" + ((accordionJson[i].EPropertyTax) * 0.01).toFixed(2) + "</td>";
                html += "<td>" + ((accordionJson[i].EPersonalTax) * 0.01).toFixed(2) + "</td>";
                html += "<td>" + ((accordionJson[i].ETotalTax) * 0.01).toFixed(2) + "</td>";

                html += "</tr>";
            });
        })
        $("#accordiondPrint").empty().append(html);
    }

    /*
  * 打印
  */
    $(function () {
        $("#btnPrint").click(function () {
            var checkId = CheckboxValueIDs();
            if (checkId.length == 0) {
                layer.msg("请选择要打印的信息！");                                                             //未选中任何行
                return;
            }
            if (checkId.length > 1) {
                layer.msg("只能选择一条信息");                                                             //未选中任何行
                return;
            }
            GetAccordionMenu();
            //Lodop打印控件
            var LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
            LODOP = getLodop();
            LODOP.PRINT_INIT("打印汇总单");
            LODOP.ADD_PRINT_HTM(95, 40, 701, 800, document.getElementById("form1").innerHTML);
            LODOP.SET_PRINT_STYLEA(0, "FontSize", 15);
            LODOP.PREVIEW();
        })
    })

    /** 刷新**/

    $(function () {
        $("#btnRefresh").click(function () {
            Replace();
        })
    })

    /*查询*/

    $("#btnSearchFull").click(function () {
        LayerOpen('850px', '200px', '查询', $('#myModalSearch'));
    });

    /*** 汇总*/

    $("#btnInvoice").click(function () {
        OpenWindow("/Base/Zor_Summary_Operation", "汇总", 1250, 500);
    });
    /**
    * 取消汇总
    */
    $(function () {
        $("#btnUpdate").click(function () {
            var checkId = CheckboxValueIDs();
            var accpid = getTableCell(7);

            if (checkId.length == 0) {
                layer.msg("请选择要取消汇总的信息！");                                                             //未选中任何行
                return;
            }
            if (checkId.length > 1) {
                layer.msg("只能选择一条信息");                                                             //未选中任何行
                return;
            }

            ZorPostSimpleData("/Base/CancelSummary", JSON.stringify({ "Dn_Id": checkId[0], "accpid": accpid }), function (data) {
                layer.msg(data.AnswerMeg, function () {
                    layer.closeAll();
                    Replace();
                });
            });
        })


        /***汇总详情*/
        $("#btnMessage").click(function () {
            var checkId = CheckboxValueIDs();//消号主id
            if (checkId.length == 0) {
                layer.msg("请选择要查看详情的信息！");                                                             //未选中任何行
                return;
            }
            if (checkId.length > 1) {
                layer.msg("只能选择一条信息");                                                             //未选中任何行
                return;
            }
            LayerOpen('1180px', '500px', '详情列表', $('#myModalMessage'));
            var html = "";
            getAjax("/Base/Disannul_Operation", { where: checkId[0] }, function (data) {
                accordionJson = eval("(" + data + ")");
                $.each(accordionJson, function (i) {
                    html += "<tr>";
                    html += "<td hidden>" + accordionJson[i].Sm_Id + "</td>";
                    html += "<td>" + accordionJson[i].CommunityName + "</td>";
                    html += "<td>" + accordionJson[i].Acceptance_TicketNumber + "</td>";
                    html += "<td>" + ((accordionJson[i].ETax) * 0.01).toFixed(2) + "</td>";
                    html += "<td>" + DataIntToDate(accordionJson[i].Acceptance_TaxStartTime, 'yyyy-MM-dd hh:mm:ss') + "</td>";
                    html += "<td>" + DataIntToDate(accordionJson[i].Acceptance_TaxEndTime, 'yyyy-MM-dd hh:mm:ss') + "</td>";
                    html += "<td>" + DataIntToDate(accordionJson[i].Pt_Date, 'yyyy-MM-dd hh:mm:ss') + "</td>";
                    html += "<td>" + accordionJson[i].InUser + "</td>";
                    html += "<td>" + accordionJson[i].AHA + "</td>";
                    html += "<td>" + accordionJson[i].NatPer_Name + "</td>";
                    html += "<td>" + accordionJson[i].NatPer_Phone + "</td>";
                    html += "<td>" + accordionJson[i].Hs_Proportion + "</td>";
                    html += "</tr>";
                });
            })
            $("#accordiond").empty().append(html);

        })
    })


</script>
